# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
from jms.dm import jms_dm__dm_cn_departure_transfer_timely_route_dt

jms_dm__dm_cn_departure_transfer_timely_route_agg_dt = SparkSqlOperator(
    task_id='jms_dm__dm_cn_departure_transfer_timely_route_agg_dt',
    email=['zhangqinglin@jtexpress.com','yl_bigdata@yl-scm.com'],
    name='jms_dm__dm_cn_departure_transfer_timely_route_agg_dt_{{ execution_date | date_add(1) | cst_ds }}',
    email_on_retry=True,
    sql='jms/dm/dm_cn_departure_transfer_timely_route_agg_dt/execute.sql',
    yarn_queue='pro',
    driver_memory='3G' , 
    driver_cores=2 , 
    executor_memory='2G' , 
    executor_cores=2 , 
    pool_slots=5,
    pool='unlimited_pool',
    retries=0,
    num_executors=2 , 
    conf={
        'spark.executor.memoryOverhead'             : '2G' , 
          'spark.dynamicAllocation.enabled': 'true',
          'spark.shuffle.service.enabled': 'true',
        'spark.dynamicAllocation.maxExecutors'             : 2 , 
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',
          'spark.dynamicallocation.enabled': 'true',
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 120,
          'spark.sql.shuffle.partitions': 600
          },

    execution_timeout=timedelta(hours=3),
    priority_weight=20,
)

jms_dm__dm_cn_departure_transfer_timely_route_agg_dt << [
    jms_dm__dm_cn_departure_transfer_timely_route_dt,
]
